<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>注册页面</title>
</head>

<body>
    登录页面
    <br />
    邮箱<input type="text" id="email" /> <br />
    密码<input type="password" id="password"> <br />
    重复密码<input type="password" id="repassword"> <br />
    <button id="getCodeBtn">获取验证码</button><br />
    邮箱验证码<input type="text" id="code1"> <br />
    <a href="./login.html">去登录</a>
    <button id="registerBtn">注册</button>

    <script src="./jquery.3.3.1.min.js"></script>
    <script src="jquery.cookie-1.4.1.min.js"></script>
    <script>

        var getCodeBtn = $("#getCodeBtn");
        getCodeBtn.click(function () {
            var email = $("#email").val();
            var url = "http://local.nick.xin/api/code/create/" + email;
            $.get(url, function (data) {
                alert("已发送，请注意邮箱：" + email);
            })
        })

        var registerBtn = $("#registerBtn");
        registerBtn.click(function () {
            var email = $("#email").val();
            var password = $("#password").val();
            var repassword = $("#repassword").val();
            var code1 = $("#code1").val();
            if (password != repassword) {
                alert("两次密码不相同");
                return;
            }
            var url = "http://local.nick.xin/api/user/register/" + email + "/" + repassword + "/" + code1;
            $.get(url, function (data) {
                var token = $.cookie('token')
                console.log(token);
                $.cookie('token', token)
                window.location.href = "http://local.nick.xin/static/welcome.html";
            })
        })

    </script>

</body>

</html>